<?php
	
namespace Home\Controller;
use Think\Controller;
class SearchController extends Controller {
    public function index(){
    	if(IS_GET){
    		$con=I('get.search');
			$field="ascontent,ancontent,cname,atime,answer,anasid,acid";
			$where=array('solve'=>1,'adopt'=>1,'ascontent'=>array('like',"%$con%"));
			
			//分页
			$count=D('Search')->field($field)->where($where)->count();
			$page=new \Think\Page($count,1);
			$this->assign('page',$page->show());
			
			$result=D('Search')->field($field)->where($where)->limit($page->firstRow.','.$page->listRows)->order('atime desc')->select();
			$this->assign('result',$result);
    	}
        $this->display('search');
    }
	
}	
